//
//  FQIViewController.swift
//  YQInformation
//
//  Created by Max on 2017/11/2.
//  Copyright © 2017年 com.vector. All rights reserved.
//

import UIKit

class FQIViewController: UIViewController {
    class func create() -> FQIViewController? {
        let s = UIStoryboard(name: "Main", bundle: nil)
        return s.instantiateViewController(withIdentifier: getClassName()) as? FQIViewController
    }
    
    class func getClassName() -> String {
        if let className = NSStringFromClass(self).components(separatedBy: ".").last {
            return className
        }
        return ""
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.automaticallyAdjustsScrollViewInsets = false
        // 统一替换返回按钮
        if self.navigationItem.leftBarButtonItem == nil {
            let btn = UIButton(type: UIButtonType.custom)
            btn.setImage(UIImage(named: "22"), for: UIControlState())
            btn.addTarget(self, action: #selector(FQIViewController.backItemPressed(_:)), for: UIControlEvents.touchUpInside)
            btn.sizeToFit()
            self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: btn)
        }
        self.navigationController?.navigationBar.titleTextAttributes =
            [NSForegroundColorAttributeName: UIColor.black]
        self.navigationController?.navigationBar.barTintColor = UIColor.white
        self.navigationController?.navigationBar
            .setBackgroundImage(UIImage(named: ""), for: .default)
        
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .any, barMetrics: .default)
        self.navigationController?.navigationBar.shadowImage = UIImage()
        
        
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func backItemPressed(_ sender:AnyObject) {
        _ = self.navigationController?.popViewController(animated: true)
    }
}
